<template>
  <div id="app">
    <div id="nav">
      <!-- <router-link to="/about">About</router-link> -->
    </div>
    <router-view/>
  </div>
</template>
<script>
import storage from './storage/index'
export default {
  components:{

  },
  data() {
    return{

    }
  },
  mounted(){
// storage.setItem('a',1)
// storage.setItem('user',{a:1})
if(this.$cookie.get('userId')){
this.getUer();
this.getCartCout()

}
  },
  methods:{
    getUer(){
     this.axios.get('/user').then((res) => {
       //to-do保存到vuex里面
    this.$store.dispatch('saveUserName',res.username);

     })
    
  },
    getCartCout(){
    this.axios.get('/carts/products/sum').then((res) => {
       //to-do保存到vuex里面
    this.$store.dispatch('saveCartCount',res);
     })
    }
}
}
</script>

<style lang="scss">
@import './assets/scss/reset.scss';
@import './assets/scss/config.scss';
@import './assets/scss/button.scss';
</style>



